This is an result for the gene singatures as well as assigned cell type for each cluster based on Danaher et al.

knitr::opts_chunk$set(cache=TRUE)

for( i in 1:length(mean_score[1,])){
print(visualize_me(mean_score[,i],cell_list[i],analysis_results$tsne[c("TSNE.1","TSNE.2")],title=names(cell_list)[i]))

#print(plot(mean_score[,i],type = "h",xlab="Single Cell",ylab=colnames(mean_score)[i]))
h <-hist(mean_score[,i],plot = FALSE)

h<- plot(h, freq = TRUE, labels =TRUE, ylim=c(0, 1.2*max(h$counts)),main=c(names(cell_list)[i]," Score per Single Cell"),xlab=paste(sep=" ",names(cell_list)[i],"Expression Level"),ylab="Numbers of cells")
#lay_out(list(h, 1, 1),
#       list(vm, 1, 2))
}

sig_plot <- visualize_clusters(cluster_tsne$cell_type,cluster_tsne[c("TSNE.1","TSNE.2")],title="Danaher cell-type labels",legend_anno= sort(unique(cluster_tsne[,"name_type"])))+scale_color_manual(values = colorRampPalette(c("blue", "red","yellow"))( length(sort(unique(cluster_tsne[,"name_type"])))))+  annotate("text", x = tsne_center[, 1], y = tsne_center[, 2], size = 5,label=c(1:length(tsne_center[,1])))

sig_plot

counter <-1
colnames(score_by_cluster) <- names(cell_list)
apply(score_by_cluster, 1,function(x) {plot(x,ylab="mean expression level per cell",xlab="cell type", main=c("Cluster",counter))
text(x, names(cell_list), cex=0.6, pos=4, col="red")
sum_table <- kable(all_type_expr_table[all_type_expr_table$Cluster == counter,])
print(sum_table)
cat("\n")
counter <<- counter + 1})

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
3 1 B_cells 28 55 1.527778 2.360219 963 2.9075805 0.00519210799584631 5 1.55951876084647
4 1 CD45 480 1681 3.502083 3.303695 963 49.8442368 0.811007268951194 781 42.485291572496
5 1 CD8_T_cells 39 114 2.651163 2.869244 963 4.0498442 0.0306334371754933 29.5 5.54526825320471
6 1 Cytotoxic_cells 303 1376 3.192575 4.026371 963 31.4641745 0.101246105919003 97.5 14.522740788157
7 1 Exhausted_CD8 161 284 1.690476 1.945215 963 16.7185877 0.0490654205607477 47.25 3.96074487943871
8 1 Macrophages 832 5571 5.435122 3.699126 963 86.3966771 0.63447559709242 611 24.7512625940577
9 1 Neutrophils 311 654 1.826816 2.112563 963 32.2949117 0.061415220293725 59.1428571428571 3.70328039909021
10 1 NK_CD56dim_cells 21 21 1.000000 0.000000 963 2.1806854 0.00545171339563863 5.25 1.14564392373896
11 1 NK_cells 6 25 3.571429 3.207135 963 0.6230530 0.00346140533056421 3.33333333333333 1.49071198499986
12 1 T_cells 143 638 2.913242 2.991848 963 14.8494289 0.0541709934233299 52.1666666666667 5.40318835914911
13 1 Th1_cells 9 15 1.666667 2.000000 963 0.9345794 0.0103842159916926 10 3.46410161513775
14 1 Treg 2 2 1.000000 0.000000 963 0.2076843 0.00207684319833853 2 1.4142135623731

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
15 2 B_cells 340 795 2.048969 2.444246 11716 2.9020143 0.00479875573764273 56.2222222222222 4.36597393430856
16 2 CD45 3646 9692 2.658256 2.807309 11716 31.1198361 0.420109252304541 4922 91.323600454647
17 2 CD8_T_cells 2649 11130 3.312500 3.172329 11716 22.6101058 0.221705360191192 2597.5 60.2349566281906
18 2 Cytotoxic_cells 7866 112444 5.236042 4.343983 11716 67.1389553 0.528857972004097 6196.1 104.860049589918
19 2 DC 42 60 1.428571 1.563967 11716 0.3584841 0.00128030044383749 15 2.38047614284762
20 2 Exhausted_CD8 1778 3240 1.724321 1.991355 11716 15.1758279 0.0455573574598839 533.75 13.7090298708552
21 2 Macrophages 282 408 1.441696 1.613098 11716 2.4069648 0.00657220894503243 77 4.83476990145343
22 2 Mast_cells 3 10 3.333333 4.041452 11716 0.0256060 0.000106691703653124 1.25 0.82915619758885
23 2 Neutrophils 19 25 1.315789 1.376494 11716 0.1621714 0.00024386675120714 2.85714285714286 0.67005939426049
24 2 NK_CD56dim_cells 173 268 1.540230 1.778514 11716 1.4766132 0.00411829976101058 48.25 3.92905841137543
25 2 NK_cells 402 1033 2.275330 2.524312 11716 3.4312052 0.0161602367133265 189.333333333333 10.9341463112378
26 2 T_cells 11147 103645 4.072815 3.460277 11716 95.1433936 0.657647661317856 7705 85.622556737242
27 2 Th1_cells 305 408 1.337705 1.393378 11716 2.6032776 0.0275691362239672 323 19
28 2 Treg 84 163 1.940476 2.213601 11716 0.7169682 0.00836462956640492 98 11.3137084989848

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
29 3 B_cells 207 449 1.918803 2.297094 17068 1.2127959 0.00190089315938859 32.4444444444444 2.92709774940433
30 3 CD45 4863 11961 2.459593 2.661323 17068 28.4919147 0.368291539723459 6286 99.498743710662
31 3 CD8_T_cells 4141 21377 3.926708 3.351746 17068 24.2617764 0.274255917506445 4681 85.1498678801089
32 3 Cytotoxic_cells 5187 13357 2.174345 2.566798 17068 30.3902039 0.0463557534567612 791.2 15.6422504774729
33 3 DC 8 8 1.000000 0.000000 17068 0.0468713 0.00015623779392235 2.66666666666667 0.942809041582063
34 3 Exhausted_CD8 1001 1495 1.477273 1.644003 17068 5.8647762 0.0161120224982423 275 9.08295106229247
35 3 Macrophages 248 321 1.294355 1.309436 17068 1.4530115 0.0038229435200375 65.25 4.25
36 3 Mast_cells 4 16 4.000000 3.464102 17068 0.0234357 8.78837590813218e-05 1.5 0.790569415042095
37 3 Neutrophils 31 38 1.187500 1.060660 17068 0.1816264 0.000276206099969868 4.71428571428571 0.868966075756888
38 3 NK_CD56dim_cells 137 173 1.262774 1.232346 17068 0.8026717 0.0020945629247715 35.75 3.11247489949718
39 3 NK_cells 28 51 1.593750 1.881307 17068 0.1640497 0.000703070072650574 12 2.49443825784929
40 3 T_cells 16150 139048 3.920711 3.382486 17068 94.6215139 0.601847511913132 10272.3333333333 93.5758753335733
41 3 Th1_cells 64 82 1.281250 1.278252 17068 0.3749707 0.00392547457229904 67 8.54400374531753
42 3 Treg 30 55 1.833333 2.166888 17068 0.1757675 0.00205062104523084 35 6.85565460040104

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
43 4 B_cells 58 149 2.328125 2.678869 1768 3.2805430 0.0052790346907994 9.33333333333333 1.457208560956
44 4 CD45 265 585 2.207547 2.528313 1768 14.9886878 0.18947963800905 335 23
45 4 CD8_T_cells 41 94 2.136364 2.445603 1768 2.3190045 0.0152714932126697 27 5
46 4 Cytotoxic_cells 387 1881 3.329204 3.853424 1768 21.8891403 0.071606334841629 126.6 12.271919165314
47 4 DC 1 1 1.000000 NA 1768 0.0565611 0.000188536953242836 0.333333333333333 0.333333333333333
48 4 Exhausted_CD8 99 151 1.480392 1.657449 1768 5.5995475 0.0156957013574661 27.75 2.92617497767991
49 4 Macrophages 391 769 1.835322 2.167417 1768 22.1153846 0.0698529411764706 123.5 6.97316284049068
50 4 Neutrophils 546 1239 1.998387 2.303681 1768 30.8823529 0.0601163542340013 106.285714285714 5.15870573864794
51 4 NK_CD56dim_cells 7 19 2.714286 2.927700 1768 0.3959276 0.00127262443438914 2.25 0.901387818865997
52 4 NK_cells 9 11 1.000000 0.000000 1768 0.5090498 0.00207390648567119 3.66666666666667 1.29099444873581
53 4 T_cells 259 719 2.152695 2.487936 1768 14.6493213 0.0394984917043741 69.8333333333333 5.39804491356722
54 4 Th1_cells 8 8 1.000000 0.000000 1768 0.4524887 0.00452488687782805 8 2.82842712474619

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
55 5 CD45 2 2 1.000000 0.000000 75 2.666667 0.0266666666666667 2 1.4142135623731
56 5 CD8_T_cells 1 7 7.000000 NA 75 1.333333 0.0133333333333333 1 1
57 5 Cytotoxic_cells 21 147 3.769231 4.836601 75 28.000000 0.192 14.4 6.81028633759257
58 5 Macrophages 34 177 5.205882 3.207750 75 45.333333 0.223333333333333 16.75 3.17214438511238
59 5 NK_cells 1 1 1.000000 NA 75 1.333333 0.00444444444444444 0.333333333333333 0.333333333333333
60 5 T_cells 6 35 3.181818 3.027150 75 8.000000 0.0333333333333333 2.5 1.21335164821342
61 5 Th1_cells 1 1 1.000000 NA 75 1.333333 0.0133333333333333 1 1

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
62 6 B_cells 2187 21816 4.088456 3.623682 2282 95.8369851 0.507400915376375 1157.88888888889 29.179097879928
63 6 CD45 539 1249 2.317254 2.580579 2282 23.6196319 0.299737072743208 684 32.7414110874898
64 6 CD8_T_cells 59 149 2.191177 2.638732 2282 2.5854514 0.0195004382120947 44.5 7.19374728496908
65 6 Cytotoxic_cells 377 2065 3.542024 4.473811 2282 16.5205960 0.0629710780017528 143.7 18.3191156991816
66 6 Exhausted_CD8 59 77 1.305085 1.329431 2282 2.5854514 0.00679228746713409 15.5 2.06155281280883
67 6 Macrophages 82 116 1.397590 1.592205 2282 3.5933392 0.00996932515337423 22.75 2.70416345659799
68 6 Mast_cells 1 1 1.000000 NA 2282 0.0438212 0.000109553023663453 0.25 0.25
69 6 Neutrophils 20 20 1.000000 0.000000 2282 0.8764242 0.00125203455615375 2.85714285714286 0.63887656499994
70 6 NK_CD56dim_cells 20 20 1.000000 0.000000 2282 0.8764242 0.00219106047326906 5 1.11803398874989
71 6 NK_cells 5 5 1.000000 0.000000 2282 0.2191060 0.000730353491089687 1.66666666666667 0.74535599249993
72 6 T_cells 306 1375 2.846791 3.010584 2282 13.4092901 0.0511247443762781 116.666666666667 8.71461097493425
73 6 Th1_cells 16 16 1.000000 0.000000 2282 0.7011394 0.007011393514461 16 4
74 6 Treg 1 1 1.000000 NA 2282 0.0438212 0.000438212094653812 1 1

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
75 7 B_cells 74 270 2.477064 3.065931 5900 1.2542373 0.00340866290018832 20.1111111111111 3.70018351229927
76 7 CD45 2104 6099 2.898764 2.947910 5900 35.6610169 0.503220338983051 2969 73.4506637138154
77 7 CD8_T_cells 2505 10733 3.266281 3.112894 5900 42.4576271 0.420847457627119 2483 58.2923665671587
78 7 Cytotoxic_cells 5882 283649 7.918954 5.924657 5900 99.6949153 3.56294915254237 21021.4 295.397088678951
79 7 DC 1 1 1.000000 NA 5900 0.0169492 5.64971751412429e-05 0.333333333333333 0.333333333333333
80 7 Exhausted_CD8 996 1769 1.662594 1.924216 5900 16.8813559 0.0508050847457627 299.75 10.3591746775503
81 7 Macrophages 92 151 1.641304 2.019583 5900 1.5593220 0.00449152542372881 26.5 3.20156211871642
82 7 Neutrophils 12 12 1.000000 0.000000 5900 0.2033898 0.000290556900726392 1.71428571428571 0.494871659305394
83 7 NK_CD56dim_cells 414 713 1.646651 1.908156 5900 7.0169492 0.0206779661016949 122 6.46142399166004
84 7 NK_cells 1052 2835 2.304878 2.589437 5900 17.8305085 0.0887005649717514 523.333333333333 19.2064803878506
85 7 T_cells 3853 33071 4.141641 3.509735 5900 65.3050847 0.419858757062147 2477.16666666667 47.8768675295747
86 7 Th1_cells 848 1558 1.837264 2.108493 5900 14.3728814 0.165762711864407 978 35.6089876295297
87 7 Treg 7 7 1.000000 0.000000 5900 0.1186441 0.0011864406779661 7 2.64575131106459

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
88 8 B_cells 132 635 3.489011 3.303671 202 65.3465347 0.162266226622662 32.7777777777778 3.56076007976935
89 8 CD45 16 29 1.812500 2.227667 202 7.9207921 0.0940594059405941 19 5.19615242270663
90 8 CD8_T_cells 6 18 3.000000 3.098387 202 2.9702970 0.0198019801980198 4 1.73205080756888
91 8 Cytotoxic_cells 183 1727 7.256303 4.297662 202 90.5940594 0.521287128712871 105.3 10.0583298812477
92 8 Exhausted_CD8 3 3 1.000000 0.000000 202 1.4851485 0.00371287128712871 0.75 0.433012701892219
93 8 Macrophages 59 170 2.575758 2.700773 202 29.2079208 0.10519801980198 21.25 3.07205143186113
94 8 Neutrophils 8 8 1.000000 0.000000 202 3.9603960 0.00565770862800566 1.14285714285714 0.404061017820884
95 8 NK_CD56dim_cells 1 1 1.000000 NA 202 0.4950495 0.00123762376237624 0.25 0.25
96 8 NK_cells 1 1 1.000000 NA 202 0.4950495 0.00165016501650165 0.333333333333333 0.333333333333333
97 8 T_cells 35 176 3.591837 3.174891 202 17.3267327 0.0627062706270627 12.6666666666667 2.53859103528797
98 8 Th1_cells 2 2 1.000000 0.000000 202 0.9900990 0.0099009900990099 2 1.4142135623731

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
99 9 B_cells 1 1 1.0 NA 25 4 0.00444444444444444 0.111111111111111 0.111111111111111
100 9 Cytotoxic_cells 4 4 1.0 0.000000 25 16 0.016 0.4 0.2
101 9 Macrophages 10 16 1.6 1.897367 25 40 0.11 2.75 0.901387818865997
102 9 T_cells 2 2 1.0 0.000000 25 8 0.0133333333333333 0.333333333333333 0.235702260395516

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
10 Macrophages 1 1 1 NA 1 100 0.25 0.25 0.25
10 Mast_cells 1 9 3 3.464102 1 100 1 1 1

[1] 2 3 4 5 6 7 8 9 10 11